package com.bootdo.modules.flowable.resources.api;

import com.bootdo.modules.flowable.utils.UUIDUtils;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.repository.ProcessDefinition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/flowable/processDefinition")
public class ProcessDefinitionResources {
    @Autowired
    private RuntimeService runtimeService;
    @Autowired
    private RepositoryService repositoryService;

    /**
     * @param processDefinitionKey
     * @param businessKey
     * @param formJson             格式{"a":"a","b":"b"}
     */
    @GetMapping("/startProcessInstanceByKey")
    public void startProcessInstanceByKey(String processDefinitionKey, String businessKey, String formJson) {
        if (null == businessKey || "".equals(businessKey)) {
            businessKey = UUIDUtils.uuid();
        }

        runtimeService.startProcessInstanceByKey(processDefinitionKey, businessKey, variables);

    }

}
